package com.example.ByteStream;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * @author Jason
 * @PACKAGE_NAME com.example.ByteStream
 * @Description 缓冲输入流BufferedInputStream
 * @date 2023-12-11 21:21
 */
public class BufferedInputStreamDemo {
    public static void main(String[] args) throws IOException {
        //1.创建BufferedInputStream
        FileInputStream fis = new FileInputStream("d:\\aaa.txt");
        BufferedInputStream bis = new BufferedInputStream(fis);

        //2.读取
//        int data = 0;
//        while ((data = bis.read()) != -1) {
//            System.out.print((char) data);
//        }
        byte[] buf = new byte[1024];
        int count = 0;
        while ((count = bis.read(buf)) != -1) {
            System.out.println(new String(buf, 0, count));
        }
        //3.关闭
        bis.close();

    }
}
